package com.commonlyUsedClass.innerClass;

/***
 * @ClassName: MemberInnerClass
 * @Description: 成员内部类练习
 * @Auther: 送一一块二向箔
 * @Date: 23:00 2022/2/11
 * @version : V1.0
 */
public class MemberInnerClass {
    public static void main(String[] args) {
        //要使用成员内部类就得使用如下方法
        //创建外部类对象
        MemberInnerClass memberInnerClass = new MemberInnerClass();
        //创建内部类对象
        MemberInnerClass.Inner inner = memberInnerClass.new Inner();


        //直接创建
        MemberInnerClass.Inner inner1 = new MemberInnerClass().new Inner();

        inner1.show();
    }
    //实例变量
    private String name = "张三";
    private int age = 20;
    //内部类
    class Inner{
        private String address = "北京";
        private String phone = "110";
        private String name = "李四";

        //方法
        public void show(){
            //打印外部类属性 此时有重名属性name
            System.out.println((MemberInnerClass.this.name));
            System.out.println((age));
            //打印内部类中的属性
            System.out.println((name));
            System.out.println((address));
            System.out.println((phone));
        }
    }
}
